package gfx;

import javax.microedition.khronos.opengles.GL10;

import util.GameVars;

import android.graphics.PointF;

public class PressableButton {
	private short type;
	private float width, height;
	private PointF center;
	private String str;
	private int num;
	private Image img;
	
	
	public PressableButton(short type, String str, PointF center, float width, float height, int num){
		this.width = width;
		this.height = height;
		this.center = center;
		this.str = str;
		this.type = type;
		this.num = num;
		
		switch(type){
		case GameVars.BUTTON_TYPE_MENU:
			img = new Image(GameVars.TEXTURE_MENU_BUTTON, 3, .75f);
			break;
		}
//		img = new Image(GameVars.TEXTURE_MENU_BUTTON, 3, .75f);
	}
	
	public void draw(GL10 gl){
		switch(type){
		case GameVars.BUTTON_TYPE_MENU:
			img.draw(gl, center);
			gl.glColor4f(0, 0, 0, 1);
			Glyphs.drawString(gl, str, center, GameVars.TEXT_ALIGNMENT_CENTER);
			gl.glColor4f(1, 1, 1, 1);
			break;
		}
	}

	public boolean isPressed(PointF loc){
		if(Math.abs(loc.x - center.x) < width * 0.5f)
			if(Math.abs(loc.y - center.y) < height * 0.5f)
				return true;
		return false;
	}

	public void setCenter(PointF newCenter){ center = newCenter; }
	public void setCenter(float x, float y){ 
		if(center == null)
			center = new PointF(x, y);
		center.set(x, y); 
	}
	public void setWidth(float newWidth){ width = newWidth; }
	public void setHeight(float newHeight){ height = newHeight; }
	public float getWidth(){ return width; }
	public float getHeight(){ return height; }
	public void setType(short newType){ type = newType; }
	public void setStrng(String newStr){ str = newStr; }
	public void setNum(int newNum){ num = newNum; }
	public int getNum(){ return num; }
	public PointF getLoc(){ return center; }
}
